package com.doit.day05

object _05_高阶函数 {
  def main(args: Array[String]): Unit = {
    println(jiSuanQi("2*3", (str: String) => {
      if (str.contains("*")) {
        val arr: Array[String] = str.split("\\*")
        arr(0).toInt * arr(1).toInt + ""
      } else {
        "传的啥玩意，不会算！"
      }
    }))

    val f1: String => Char => Boolean = func(1)
    val f2: Char => Boolean = f1("abc")
    val bool: Boolean = f2('c')

    val bool1: Boolean = func(1)("abc")('c')

  }

  val func: Int => String => Char => Boolean = (a:Int)=>{
    val f1 = (str:String)=>{
      val f2 = (c:Char)=>{
        if(a == 0 && str == "" && c == 'c'){
          false
        }else{
          true
        }
      }
      f2
    }
    f1
  }

  //函数的本质 接口的实现类对象
  val add :(Int,Int=>Int)=>(Int,Int)=>Int = (a:Int,op:Int=>Int)=>{
    (a:Int,b:Int)=>{a+b+op(a)}
  }

  //定义一个计算器，传一个String类型的值进去，在传一个操作进去  +-*/
  //这个项目涉及到很多的模型规则
  def jiSuanQi(str:String,op:(String)=>String)={
    op(str)
  }







}
